﻿using System;

namespace ZyGame
{
    public sealed class LongVarable : Varable<long>
    {
        public LongVarable(long value)
        {
            this.value = value;
        }

        public static implicit operator long(LongVarable varable)
        {
            return varable.value;
        }

        public static explicit operator LongVarable(long varable)
        {
            return new LongVarable(varable);
        }

        public static LongVarable operator +(LongVarable left, LongVarable right)
        {
            left.value = Math.Clamp(left.value + right.value, long.MinValue, long.MaxValue);
            return left;
        }

        public static LongVarable operator -(LongVarable left, LongVarable right)
        {
            left.value = Math.Clamp(left.value - right.value, long.MinValue, long.MaxValue);
            return left;
        }

        public static LongVarable operator *(LongVarable left, LongVarable right)
        {
            left.value = Math.Clamp(left.value * right.value, long.MinValue, long.MaxValue);
            return left;
        }

        public static LongVarable operator /(LongVarable left, LongVarable right)
        {
            left.value = Math.Clamp(left.value / right.value, long.MinValue, long.MaxValue);
            return left;
        }

        public static bool operator ==(LongVarable left, LongVarable right)
        {
            return left.value == right.value;
        }

        public static bool operator !=(LongVarable left, LongVarable right)
        {
            return left.value != right.value;
        }

        public static LongVarable test()
        {
            LongVarable varable = new LongVarable(0);
            return varable += (LongVarable)10l;
        }
    }
}
